package com.fallsvc.onlinemusic.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @auther falls_vc
 * description:
 * @date 2025/4/2  20:57
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {


    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                //排除所有的JS
                .excludePathPatterns("/js/**.js")
//排除images下所有的元素
                .excludePathPatterns("/images/")
                .excludePathPatterns("/css/**.css")
                .excludePathPatterns("/fronts/")
                .excludePathPatterns("/player/**")
                .excludePathPatterns("/login.html")
//排除登录接⼝
                .excludePathPatterns("/user/login");

    }
    @Bean
    public BCryptPasswordEncoder bCryptPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }
}
